home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol K-12 / Vol K-12.iso / interfac / it.dig / scripts / FScrollSelectListSymbol.as < prev    next >
Text File  |  2012-08-27  |  5KB  |  176 lines

  1. function FScrollSelectListClass()
  2. {
  3.    this.init();
  4. }
  5. FScrollSelectListClass.prototype = new FSelectableListClass();
  6. FScrollSelectListClass.prototype.getScrollPosition = function()
  7. {
  8.    return this.topDisplayed;
  9. };
  10. FScrollSelectListClass.prototype.setScrollPosition = function(pos)
  11. {
  12.    if(this.enable)
  13.    {
  14.       pos = Math.min(pos,this.getLength() - this.numDisplayed);
  15.       pos = Math.max(pos,0);
  16.       this.scrollBar_mc.setScrollPosition(pos);
  17.    }
  18. };
  19. FScrollSelectListClass.prototype.setAutoHideScrollBar = function(flag)
  20. {
  21.    this.permaScrollBar = !flag;
  22.    this.setSize(this.width,this.height);
  23. };
  24. FScrollSelectListClass.prototype.setEnabled = function(enabledFlag)
  25. {
  26.    super.setEnabled(enabledFlag);
  27.    this.scrollBar_mc.setEnabled(this.enable);
  28. };
  29. FScrollSelectListClass.prototype.setSize = function(w, h)
  30. {
  31.    var _loc3_ = this.getScrollPosition();
  32.    super.setSize(w,h);
  33.    if(this.scrollBar_mc != undefined)
  34.    {
  35.       this.removed = true;
  36.    }
  37.    this.scrollBar_mc = undefined;
  38.    this.initScrollBar();
  39.    this.setScrollPosition(_loc3_);
  40. };
  41. FScrollSelectListClass.prototype.modelChanged = function(eventObj)
  42. {
  43.    super.modelChanged(eventObj);
  44.    this.invalidate("initScrollBar");
  45. };
  46. FScrollSelectListClass.prototype.initScrollBar = function()
  47. {
  48.    if(!this.permaScrollBar && this.getLength() <= this.numDisplayed)
  49.    {
  50.       if(this.removed)
  51.       {
  52.          this.scrollBar_mc.removeMovieClip();
  53.          this.scrollBar_mc = undefined;
  54.          this.scrollOffset = undefined;
  55.          this.invalidate("setSize");
  56.       }
  57.    }
  58.    else
  59.    {
  60.       if(this.scrollBar_mc == undefined)
  61.       {
  62.          this.container_mc.attachMovie("FScrollBarSymbol","scrollBar_mc",3000,{hostStyle:this.styleTable});
  63.          this.scrollBar_mc = this.container_mc.scrollBar_mc;
  64.          this.scrollBar_mc.setChangeHandler("scrollHandler",this);
  65.          this.scrollBar_mc.setSize(this.height);
  66.          this.scrollBar_mc._x = this.width - this.scrollBar_mc._width;
  67.          this.scrollBar_mc._y = 0;
  68.          this.scrollBar_mc.setLargeScroll(this.numDisplayed - 1);
  69.          this.scrollOffset = this.scrollBar_mc._width;
  70.          this.invalidate("setSize");
  71.       }
  72.       this.scrollBar_mc.setScrollProperties(this.numDisplayed,0,this.getLength() - this.numDisplayed);
  73.    }
  74. };
  75. FScrollSelectListClass.prototype.scrollHandler = function(scrollBar)
  76. {
  77.    var _loc2_ = scrollBar.getScrollPosition();
  78.    this.topDisplayed = _loc2_;
  79.    if(this.lastPosition != _loc2_)
  80.    {
  81.       this.updateControl();
  82.    }
  83.    this.lastPosition = _loc2_;
  84. };
  85. FScrollSelectListClass.prototype.clickHandler = function(itmNum)
  86. {
  87.    super.clickHandler(itmNum);
  88.    if(this.dragScrolling == undefined && this.scrollBar_mc != undefined)
  89.    {
  90.       this.dragScrolling = setInterval(this,"dragScroll",15);
  91.    }
  92. };
  93. FScrollSelectListClass.prototype.releaseHandler = function()
  94. {
  95.    clearInterval(this.dragScrolling);
  96.    this.dragScrolling = undefined;
  97.    super.releaseHandler();
  98. };
  99. FScrollSelectListClass.prototype.dragScroll = function()
  100. {
  101.    clearInterval(this.dragScrolling);
  102.    if(this.container_mc._ymouse < 0)
  103.    {
  104.       this.setScrollPosition(this.getScrollPosition() - 1);
  105.       this.selectionHandler(0);
  106.       this.scrollInterval = Math.max(25,-23.8 * (- this.container_mc._ymouse) + 500);
  107.       this.dragScrolling = setInterval(this,"dragScroll",this.scrollInterval);
  108.    }
  109.    else if(this.container_mc._ymouse > (this.itmHgt - 2) * this.numDisplayed)
  110.    {
  111.       this.setScrollPosition(this.getScrollPosition() + 1);
  112.       this.selectionHandler(this.numDisplayed - 1);
  113.       this.scrollInterval = Math.max(25,-23.8 * Math.abs(this.container_mc._ymouse - (this.itmHgt - 2) * this.numDisplayed - 2) + 500);
  114.       this.dragScrolling = setInterval(this,"dragScroll",this.scrollInterval);
  115.    }
  116.    else
  117.    {
  118.       this.dragScrolling = setInterval(this,"dragScroll",15);
  119.    }
  120. };
  121. FScrollSelectListClass.prototype.myOnKeyDown = function()
  122. {
  123.    if(this.focused)
  124.    {
  125.       this.keyCodes = new Array(40,38,34,33,36,35);
  126.       this.keyIncrs = new Array(1,-1,this.numDisplayed - 1,- (this.numDisplayed - 1),- this.getLength(),this.getLength());
  127.       var _loc2_ = 0;
  128.       while(_loc2_ < this.keyCodes.length)
  129.       {
  130.          if(Key.isDown(this.keyCodes[_loc2_]))
  131.          {
  132.             this.moveSelBy(this.keyIncrs[_loc2_]);
  133.             return undefined;
  134.          }
  135.          _loc2_ = _loc2_ + 1;
  136.       }
  137.       this.findInputText();
  138.    }
  139. };
  140. FScrollSelectListClass.prototype.findInputText = function()
  141. {
  142.    var _loc2_ = Key.getAscii();
  143.    if(_loc2_ >= 33 && _loc2_ <= 126)
  144.    {
  145.       this.findString(String.fromCharCode(_loc2_));
  146.    }
  147. };
  148. FScrollSelectListClass.prototype.findString = function(str)
  149. {
  150.    if(this.getLength() == 0)
  151.    {
  152.       return undefined;
  153.    }
  154.    var _loc4_ = this.getSelectedIndex();
  155.    var _loc6_ = 0;
  156.    var _loc2_ = _loc4_ + 1;
  157.    while(_loc2_ != _loc4_)
  158.    {
  159.       var _loc3_ = this.getItemAt(_loc2_).label.substring(0,str.length);
  160.       if(str == _loc3_ || str.toUpperCase() == _loc3_.toUpperCase())
  161.       {
  162.          _loc6_ = _loc2_ - _loc4_;
  163.          break;
  164.       }
  165.       if(_loc2_ >= this.getLength() - 1)
  166.       {
  167.          _loc2_ = -1;
  168.       }
  169.       _loc2_ = _loc2_ + 1;
  170.    }
  171.    if(_loc6_ != 0)
  172.    {
  173.       this.moveSelBy(_loc6_);
  174.    }
  175. };
  176.